package com.example.client;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author annvcit
 * @full_name Nguyen Van Chuc An
 * @email annvcit@gmail.com
 * @date_created Dec 25, 2014
 *
 */
public class Client {
    public static void main(String[] args) {
        ImplVerifyService client = new ImplVerifyService();
        ImplVerify service = client.getImplVerifyPort();
        
        String fileName = "binary.jpg";
        String filePath = "/home/annvcit/Desktop/test_webservice/client/upload/"
                + fileName;
        
        File file = new File(filePath);
        
        
     // uploads a file
        try {
            FileInputStream fis = new FileInputStream(file);
            BufferedInputStream inputStream = new BufferedInputStream(fis);
            byte[] fileBytes = new byte[(int) file.length()];
            inputStream.read(fileBytes);

            boolean isLargeSize = service.verify(fileName, fileBytes);
            System.out.println("uploaded && size > 10 byte? " + isLargeSize);

            inputStream.close();
        } catch (IOException ex) {
            System.err.println(ex);
        }
        
    }
}
